package com.zyj.exoplayerdemo

import android.app.Application
import com.google.android.exoplayer2.database.ExoDatabaseProvider
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor
import com.google.android.exoplayer2.upstream.cache.SimpleCache

/**
 * @Description:
 * @author: zhaoyj
 * @date: 2022/6/14
 */
class MyApp : Application() {

    companion object {
        lateinit var cache: SimpleCache
    }

    //视频缓存最大容量 90M
    private val cacheSize: Long = 90 * 1024 * 1024
    private lateinit var cacheEvictor: LeastRecentlyUsedCacheEvictor
    private lateinit var exoplayerDatabaseProvider: ExoDatabaseProvider

    override fun onCreate() {
        super.onCreate()

        cacheEvictor = LeastRecentlyUsedCacheEvictor(cacheSize)
        exoplayerDatabaseProvider = ExoDatabaseProvider(this)
        cache = SimpleCache(externalCacheDir!!, cacheEvictor, exoplayerDatabaseProvider)
    }
}